﻿using System;
using System.Collections.Generic;

namespace Sizebox.CharacterEditor
{
	// Token: 0x02000280 RID: 640
	[Serializable]
	internal class WeldData
	{
		// Token: 0x06000E12 RID: 3602 RVA: 0x0006DDD9 File Offset: 0x0006BFD9
		public WeldData(string objectName)
		{
			this.objectName = objectName;
			this.reusableIndexes = new Queue<int>();
			this.weldIndexMap = new Dictionary<string, int>();
		}

		// Token: 0x06000E13 RID: 3603 RVA: 0x0006DE00 File Offset: 0x0006C000
		public string Add()
		{
			string text = this.GenerateObjectKey();
			this.weldIndexMap.Add(text, this.NextIndex());
			if (this.reusableIndexes.Count > 0)
			{
				this.reusableIndexes.Dequeue();
			}
			return text;
		}

		// Token: 0x06000E14 RID: 3604 RVA: 0x0006DE44 File Offset: 0x0006C044
		public void Remove(string weldKey)
		{
			if (!this.weldIndexMap.ContainsKey(weldKey))
			{
				return;
			}
			int item = this.weldIndexMap[weldKey];
			this.weldIndexMap.Remove(weldKey);
			this.reusableIndexes.Enqueue(item);
		}

		// Token: 0x06000E15 RID: 3605 RVA: 0x0006DE8C File Offset: 0x0006C08C
		private string GenerateObjectKey()
		{
			return this.objectName + this.NextIndex().ToString();
		}

		// Token: 0x06000E16 RID: 3606 RVA: 0x0006DEB8 File Offset: 0x0006C0B8
		private int NextIndex()
		{
			if (this.reusableIndexes.Count > 0)
			{
				return this.reusableIndexes.Peek();
			}
			return this.weldIndexMap.Count;
		}

		// Token: 0x04001301 RID: 4865
		public string objectName;

		// Token: 0x04001302 RID: 4866
		public Queue<int> reusableIndexes;

		// Token: 0x04001303 RID: 4867
		public Dictionary<string, int> weldIndexMap;
	}
}
